import React, { Component } from 'react';
import {Map} from 'immutable'

class Immu03 extends Component {
    state={
        info:Map({
            name:"碰磕",
            age:20,
            hobbit:Map({
                likeone:"运动",
                liketwo:"学习"
            })
        })
    }
    render() {
        return (
            <div>
                Immu03
                <button onClick={()=>{this.setState({
                    info:this.state.info.set("name","学习啊啊啊")
                })}}>修改</button>
                {this.state.info.get("name")}
                <Child hobbit={this.state.info.get("hobbit")} ></Child> 
            </div>
        );
    }
}
class Child extends Component{
    shouldComponentUpdate(nextProps,nextState){
        //判断hobbit的值是否更新
        if(this.props.hobbit===nextProps.hobbit){
            return false;
        }
        return true;
    }
    render(){
        return(
            <div>Child</div>
        );
    }
    componentDidUpdate(){
        console.log("子组件更新了");
    }
}
export default Immu03;